<?php
class Product_Model extends CI_Model 
{
    function __construct()
    {
        parent::__construct();
    }
	
	function get_hot_product()
	{
		$start = rand(0, 1);
		$query="SELECT * FROM products WHERE is_hot_product=1 and is_active=1 limit $start, 18";
		return $this->db->query($query);
	}
	
	function get_category_using_slug_parent_n_category_name($slug_category_name='', $slug_parent_category_name='' )
	{
		$query="SELECT * FROM categories WHERE slug_category_name='$slug_category_name' AND slug_parent_category_name='$slug_parent_category_name' ";
		return $this->db->query($query);
	}
	
	function get_category_list()
	{
		$query="SELECT * FROM categories where is_active=1 order by tree_order";
		return $this->db->query($query);    
	}
	
	function get_parent_category_list()
	{
		$query="SELECT * FROM categories where is_active=1 order by tree_order";
		return $this->db->query($query);    
	}
	
	function get_recent_products($start=0, $limit=10)
	{
		$query = "SELECT * FROM products where is_active=1  LIMIT $start, $limit";
		// echo $query ;
		return $this->db->query($query);
	}
	
	function get_products_using_category_id($category_id=0, $start=0, $limit=10)
	{
		$query = "SELECT *  FROM products  WHERE category_id=$category_id and is_active=1 ORDER BY post_date DESC limit $start, $limit";
		return $this->db->query($query);
	}
	
	function get_product_using_product_id($product_id=0)
	{
		$query = "SELECT * FROM products WHERE product_id=$product_id ";
		return $this->db->query($query);
	}
	
	function get_category_using_id($category_id=0)
	{
		$query = "SELECT * FROM categories WHERE category_id=$category_id";
		return $this->db->query($query);
	}
	
	function get_subdomain_link_using_category_id($category_id=0)
	{
		$query = "SELECT * FROM categories_subdomain WHERE category_id=$category_id";
		return $this->db->query($query);
	}
	
	function get_related_product($product_id){
		$query = "SELECT * FROM products pd INNER JOIN products_related pr ON pd.product_id = pr.product_id_related WHERE pr.product_id=$product_id";
		return $this->db->query($query);
	}
}

/* End of file Product_Model */
/* Location: ./application/model/Product_Model.php */